//
//  ZYDraggableController.swift
//  ZYUICommon_Example
//
//  Created by Yi Zhou on 2025/1/11.
//  Copyright © 2025 CocoaPods. All rights reserved.
//

import Foundation
import UIKit
import ZYUICommon

class ZYDraggableController: UIViewController {
    
    lazy var draggableView: ZYDraggableView = {
        let view = ZYDraggableView(frame: CGRect(origin: CGPoint(x: 100, y: 100), size: CGSize(width: 200, height: 200)))
        view.backgroundColor = ZYUtil.colorRandom()
        view.gestureType = .both
        return view
    }()
    
    lazy var backButton: UIButton = {
        return UIButton(type: .custom)
            .zyFrame(CGRect(x: zScreenWidth - 64, y: zScreenHeight - zSafeBottomMargin - 64, width: 44, height: 44))
            .zyFont(16)
            .zyNormalTextColor(.white)
            .zyBackgroundColor(ZYUtil.colorRandom())
            .zyNormalText("返回")
            .zyAllCornerRadius(22)
            .zyAddTarget { [weak self] in
                guard let weakSelf = self else { return }
                weakSelf.dismiss(animated: true)
            }
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        view.addSubview(draggableView)
        view.addSubview(backButton)
    }
    
}
